package com.example.study_manger.repository;
import com.example.study_manger.entity.Role;
import com.example.study_manger.entity.TrainingDocument;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface TrainingDocumentRe extends JpaRepository<TrainingDocument, Long>, JpaSpecificationExecutor<TrainingDocument> {
    @Query("select t from TrainingDocument t where t.organization.id = ?1 or t.role.roleName = ?2")
    List<TrainingDocument> findByOrganizationIdOrRole(long l, String superAdmin);

    @Query("select t from TrainingDocument t where t.role.roleName = ?1")
    List<TrainingDocument> findAllByRole_roleName(String superAdmin);
}
